package com.xieyingwangluo.yxpart.mapper;

import com.xieyingwangluo.yxpart.entity.AdminModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface AdminMapper {

    // 添加
    int add(AdminModel adminModel);

    //删除
    int del(@Param("noid") String noid);

    //编辑用户信息
    /*  @Update("update user set tel=#{tel},pwd=#{pwd},name=#{name},head_img=#{head_img},power=#{power},state=#{state} where noid=#{noid}")*/
    int upd(AdminModel adminModel);

    //根据id获取用户信息
    AdminModel selO(@Param("noid") String noid);

    //获取用户列表
    List<AdminModel> selA(AdminModel adminModel);

    //管理员登录
    @Select("select noid,tel,name,head_img,power,state,create_time from admin where name=#{name} and pwd=#{pwd}")
    AdminModel checklogin(@Param("name") String name, @Param("pwd") String pwd);

    //更新管理员密码
    @Update("update admin set pwd=#{pwd} where noid=#{noid}")
    int updPwd(@Param("noid") String noid, @Param("pwd") String pwd);

    //根据电话查询用户信息
    @Select("select * from admin where tel=#{tel}")
    List<AdminModel> selT(@Param("tel") String tel);

    //管理员登录
    @Select("select noid,tel,name,head_img,power,state,create_time from admin where tel=#{tel} and pwd=#{pwd}")
    AdminModel login(@Param("tel") String tel, @Param("pwd") String pwd);
}
